package j04arraylist;

import java.util.ArrayList;
import java.util.Random;

public class J1 {
    public static void main(String[] args) {
        //引用
        ArrayList<String> arrayList = new ArrayList<>();

        ArrayList<String> arrayList2 = new ArrayList<String>();
        ArrayList arrayList3 = new ArrayList();

        arrayList.add("aa");
        arrayList.add("bb");
        arrayList.add("ff");
        System.out.println("arrayList = " + arrayList);
        arrayList.add(1,"xx");
        System.out.println("arrayList = " + arrayList);
        System.out.println("====");
        ArrayList<String> arr1 = new ArrayList<>();
        arr1.add("x");
        arr1.add("y");
        arr1.add("z");

        ArrayList<String> arr2 = new ArrayList<>();
        arr2.addAll(arr1);
        arr2.add("kkk");
        arr2.add("kkk");
        System.out.println("arr2 = " + arr2);

        ArrayList<String> arr3 = new ArrayList<>(arr1);
        System.out.println("arr3 = " + arr3);

        //泛型
//        arr3.add(new Random());

    }
}
